home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2001 September / PC-WELT 9-2001.ISO / software / hw / brennen / flask_src.exe / Input / DVDselector.cpp next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  4.8 KB  |  173 lines

  1. /* 
  2.  *  SelectorDialog.cpp
  3.  *
  4.  *    Copyright (C) Alberto Vigata - January 2000
  5.  *
  6.  *  This file is part of FlasKMPEG, a free MPEG to MPEG/AVI converter
  7.  *    
  8.  *  FlasKMPEG is free software; you can redistribute it and/or modify
  9.  *  it under the terms of the GNU General Public License as published by
  10.  *  the Free Software Foundation; either version 2, or (at your option)
  11.  *  any later version.
  12.  *   
  13.  *  FlasKMPEG is distributed in the hope that it will be useful,
  14.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  *  GNU General Public License for more details.
  17.  *   
  18.  *  You should have received a copy of the GNU General Public License
  19.  *  along with GNU Make; see the file COPYING.  If not, write to
  20.  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  21.  *
  22.  */
  23.  
  24. #include <windows.h>
  25. #include <stdio.h>
  26. #include "..\resource.h"
  27. #include "..\auxiliary.h"
  28. #include "..\RunState.h"
  29. #include "..\language.h"
  30. #include "..\misc\selectordialog.h"
  31. #include ".\IFOParser\ifoparser.h"
  32. #include "DVDSelector.h"
  33.  
  34. extern TRunState rs;
  35. //global
  36. struct TPGCnumberToListBox
  37. {
  38.     int pgc;
  39.     int angle;
  40.  
  41. };
  42.  
  43. OpenDVDSelector(HWND hWnd, HINSTANCE hInst, CIFOParser *ifo, TDVDSelector *sel_info)
  44. {
  45.     int i,j, titles_count;
  46.     CArr<char *> str;
  47.     CArr<TPGCnumberToListBox>  pgc_rel;
  48.     TPGCnumberToListBox        spgc_rel;
  49.     char szTemp[256];
  50.     int audio_section_number  = 0;
  51.     int subpic_section_number = 0;
  52.  
  53.  
  54.     TSelectorDialog set;
  55.     set.tittle      =   GS(DVS_TITLE);
  56.     set.button_text =   GS(DVS_BUTTON);
  57.     set.lateral_text =  GS(DVS_LATERAL);
  58.  
  59.     set.section_count = 0;
  60.  
  61.     set.sections_titles[0] = GS(DVS_PGCSFOUND);
  62.     set.sections_titles[1] = GS(DVS_AUDIOFOUND);
  63.     set.sections_titles[2] = GS(DVS_SUBPICFOUND);
  64.  
  65.     set.section_mode[0]   =SINGLE_SELECT | MUST_SELECT;
  66.     set.section_mode[1]   =SINGLE_SELECT | MUST_SELECT;
  67.     set.section_mode[2]   =SINGLE_SELECT;
  68.  
  69.     titles_count = 0;
  70.     for(i=0; i<ifo->PGCs.GetCount(); i++)
  71.     {
  72.         for(j=0; j < ifo->PGCs[i].BuiltPGC.GetCount(); j++)
  73.         {    
  74.             spgc_rel.pgc   = i;
  75.             spgc_rel.angle = j;
  76.             pgc_rel.AddItem(&spgc_rel);
  77.  
  78.             titles_count++;
  79.                        str.SetArraySize(titles_count);
  80.             set.strings[0].SetArraySize(titles_count);
  81.             str[titles_count-1] = new char[256];
  82.  
  83.             MillisecondsToTime(szTemp, ifo->PGCs[i].BuiltPGC[j].chain_time );
  84.  
  85.             if(ifo->PGCs[i].BuiltPGC.GetCount()>1)
  86.                 sprintf(str[titles_count-1] , "%d.-  %s: %s - (%s %d)", i,GS(DVS_DURATION) ,szTemp,GS(DVS_ANGLE), j);
  87.             else
  88.                 sprintf(str[titles_count-1] , "%d.-  %s: %s", i,GS(DVS_DURATION) ,szTemp);
  89.  
  90.             set.strings[0][titles_count-1] = (char *)str[titles_count-1];
  91.         }
  92.     }
  93.     // A pgc must be inside the stream
  94.     set.section_count++;
  95.  
  96.     if( ifo->GetAudioCount() ){
  97.         audio_section_number = set.section_count;
  98.         set.section_count++;
  99.         set.strings[audio_section_number].SetArraySize( ifo->GetAudioCount() );
  100.         for(i=0; i<ifo->AudioCount; i++)
  101.             set.strings[audio_section_number][i]= ifo->AudioID[i];
  102.     }
  103.  
  104.     if( ifo->GetSubpicCount() ){
  105.         subpic_section_number = set.section_count;
  106.         set.section_count++;
  107.         set.strings[subpic_section_number].SetArraySize( ifo->GetSubpicCount() );
  108.         for(i=0; i<ifo->SubpicCount; i++)
  109.             set.strings[subpic_section_number][i] = ifo->SubpidID[i];
  110.     }
  111.  
  112.  
  113.     // ResetSelections MUST be called before OpenSelectorDialog or setting default selections
  114.     //      in order to initialize selections.
  115.     ResetSelections(&set);
  116.  
  117.     sel_info->has_audio  = 0;
  118.     sel_info->has_subpic = 0;
  119.  
  120.     set.selected[0][0] = 1;
  121.     if( ifo->GetAudioCount() )
  122.         set.selected[audio_section_number][0] = 1;
  123.  
  124.     if( ifo->GetSubpicCount() )
  125.         set.selected[subpic_section_number][0] = 0;
  126.  
  127.     OpenSelectorDialog(hWnd, hInst, &set);
  128.  
  129.     // Get PGC and angle
  130.     i=0;
  131.     int selected;
  132.     for(i=0; i<set.selected[0].GetCount(); i++)
  133.         if(set.selected[0][i]>0)
  134.             break;
  135.     selected = i;
  136.  
  137.     sel_info->selected_pgc   = pgc_rel[selected].pgc;
  138.     sel_info->selected_angle = pgc_rel[selected].angle;
  139.  
  140.     // Get audios
  141.     if(sel_info->has_audio      = audio_section_number){
  142.         // FIXME: When multiaudio is available check this one
  143.         i=0;
  144.         while( i < set.strings[subpic_section_number].GetCount() ){
  145.             if(set.selected[audio_section_number][i]==1)
  146.                 break;
  147.             i++;
  148.         }
  149.             sel_info->selected_audio = i;
  150.             sel_info->audio_type     = ifo->AudioMode[i];
  151.     }
  152.  
  153.     // Get subpics
  154.     if(sel_info->has_subpic      = subpic_section_number){
  155.         i=0;
  156.         while( i < set.strings[subpic_section_number].GetCount() ){
  157.             if( set.selected[subpic_section_number][i]==1 )
  158.                 break;
  159.             i++;
  160.         }
  161.         if( i==set.strings[subpic_section_number].GetCount() )
  162.             sel_info->has_subpic = 0;
  163.         else
  164.             sel_info->selected_subpic = i;
  165.     }
  166.  
  167.     
  168.     // Delete temporary strings used for the dialog
  169.     for(i=0; i<str.GetCount(); i++)
  170.         delete [] str[i];
  171.     return 1;
  172.  
  173. }